package com.tripwego.client.ui.pageAccueil;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.tripwego.client.ui.widget.EtapeWidget;

public class HomeWidget extends Composite implements IHomeView {

	private Presenter presenter;

	private EventBus eventBus;

	/*
	 * Elements graphiques
	 */
	private VerticalPanel viewPanel = new VerticalPanel();

	EtapeWidget etapeWidget;
	private final HorizontalPanel horizontalPanel_header = new HorizontalPanel();
	private final Image image_banner = new Image("icons/logo_tripwego.png");
	private final HorizontalPanel horizontalPanel_middle = new HorizontalPanel();
	private final VerticalPanel verticalPanel_right = new VerticalPanel();
	private final ListTripWidget listTripWidget = new ListTripWidget();
	private final HorizontalPanel horizontalPanel_footer = new HorizontalPanel();
	// private final Image image_map = new Image("icons/map_home.png");

	private FormCreateTripWidget formCreateTripWidget = new FormCreateTripWidget();

	/**
	 * 
	 */
	public HomeWidget() {
		super();
		viewPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

		viewPanel.setSize("968px", "500px");

		viewPanel.setStylePrimaryName("HomeWidget");

		viewPanel.add(horizontalPanel_header);
		horizontalPanel_header.setWidth("100%");

		viewPanel.add(formCreateTripWidget.asWidget());

		horizontalPanel_header.add(image_banner);

		viewPanel.add(horizontalPanel_middle);
		horizontalPanel_middle.setSize("100%", "");
		// horizontalPanel_middle.add(image_map);
		// verticalPanel_right.setBorderWidth(1);

		horizontalPanel_middle.add(verticalPanel_right);
		verticalPanel_right.setSize("", "");

		verticalPanel_right.add(listTripWidget.asWidget());

		viewPanel.add(horizontalPanel_footer);
		horizontalPanel_footer.setWidth("100%");
	}

	@Override
	public Widget asWidget() {
		init();
		return viewPanel;
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
		this.formCreateTripWidget.setPresenter(presenter);
		this.listTripWidget.setPresenter(presenter);
	}

	@Override
	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;
		this.formCreateTripWidget.setEventBus(eventBus);
		this.listTripWidget.setEventBus(eventBus);
	}

	@Override
	public void init() {
		formCreateTripWidget.init();
	}
}
